from typing import *


class Solution:

    def numSubarrayProductLessThanK(self, nums: List[int], k: int) -> int:
        mul, j = 1, 0
        ans = 0
        for i, v in enumerate(nums):
            mul *= v
            while j <= i and mul >= k:
                mul //= nums[j]
                j += 1
            ans += i - j + 1
        return ans